#include "bonus.h"

Bonus* newBonus(int x, int y, int raio, char tipo, int cor)
{
	Bonus* b = (Bonus*)malloc(sizeof(Bonus));
	b->x = x;
	b->y = y;
	b->raio = raio;
	b->tipo = tipo;
	b->cor = cor;
	return b;
}

void drawBonus(Bonus* b, char* base)
{
	int dx = -b->raio;
	for(; dx <= b->raio; dx++)
	{
		int dy = (int)(b->raio * sin(acos(dx / (float)b->raio)) );
		draw_line(b->x + dx, b->y - dy, b->x + dx, b->y + dy, b->cor, base);
		set_pixel(b->x + dx, b->y + dy, BRIGHT, base);
		set_pixel(b->x + dx, b->y - dy, b->cor | BRIGHT, base);
	}
}

void eraseBonus(Bonus* b, char* base)
{
	int dx = -b->raio;
	for(; dx <= b->raio; dx++)
	{
		int dy = (int)(b->raio * sin(acos(dx / (float)b->raio)) );
		draw_line(b->x + dx, b->y - dy , b->x + dx, b->y + dy, BLACK, base);
	}
}
